<template>
  <div>
    <el-table
      :data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
      style="width: 100%">
      <el-table-column
        label="pic"
        prop="pic">
        <template slot-scope="scope" >
          <img style="height: 100px;width: 100px" src="https://h2.appsimg.com/a.appsimg.com/upload/merchandise/pdcvis/2022/06/17/172/bd16bae4-e0ef-4025-ae9d-9cbbce01865c.jpg">
        </template>
      </el-table-column>
      <el-table-column
        label="name"
        prop="name">
      </el-table-column>
      <el-table-column
        label="price"
        prop="price">
      </el-table-column>
      <el-table-column
        label="quantity"
        prop="quantity">
      </el-table-column>
      <el-table-column
        align="right">
        <template slot="header" slot-scope="scope">
          <el-input
            v-model="search"
            size="mini"
            placeholder="输入关键字搜索"/>
        </template>
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)">Delete</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [{
        name: '夏季拼色POLO领格纹针织衫女减龄短款上衣',
        price:88,
        quantity:10
      },{
        name: '夏季拼色POLO领格纹针织衫女减龄短款上衣',
        price:88,
        quantity:10
      },{
        name: '夏季拼色POLO领格纹针织衫女减龄短款上衣',
        price:88,
        quantity:10
      },{
        name: '夏季拼色POLO领格纹针织衫女减龄短款上衣',
        price:88,
        quantity:10
      },
      ],
      search: ''
    }
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    }
  },
}
</script>

<style scoped>

</style>
